package main

import (
	"os"

	"gitlab.yunzhen-data.com/C-Chain/titan"
	"gitlab.yunzhen-data.com/C-Chain/titan/httpengine"
	"gitlab.yunzhen-data.com/C-Chain/titan/httpengine/middlewares"
	"gitlab.yunzhen-data.com/C-Chain/titan/log"
	"gitlab.yunzhen-data.com/C-Chain/titan/starts"

	"gitlab.yunzhen-data.com/C-Chain/titan-template/clients"
	"gitlab.yunzhen-data.com/C-Chain/titan-template/configurations"
	"gitlab.yunzhen-data.com/C-Chain/titan-template/controllers"
	"gitlab.yunzhen-data.com/C-Chain/titan-template/services"
)

func main() {
	var err error

	application := titan.NewDefaultApplication(
		// 配置类
		httpengine.NewHTTPConfiguration(),
		httpengine.NewGinConfiguration(),
		log.NewConfiguration(),
		configurations.NewHTTPClientConfiguration(),

		// 启动类
		starts.NewCommandParserStarter(),
		starts.NewLogStarter(),
		starts.NewHTTPStarter(),
		clients.NewHTTPClientStarter(),

		// 过滤器
		middlewares.NewAccessLogFilter(),
		middlewares.NewRequestIDFilter(),

		// services
		services.NewDeployService(),

		// controllers
		controllers.NewHealthController(),
		controllers.NewDeployController(),
	)
	err = application.Create()
	if err != nil {
		log.Errorf("create application failed: %v", err)
		os.Exit(titan.ExitFailure)
	}
}
